function RMSE = rmse_SVJEJ(optiondata,Rate,Times,Price,DividendYield,v)
%% ------------------------------description------------------------------
%This function calculates the root mean squared error (RMSE) between observed
%implied volatilities and those implied by DJKS (2019) model
%optiondata = observed option data (table), variables: (1)strike_price, (2)implied_volatility
%Rate = interest rate
%Times = time-to-maturity
%Price = current stock price
%DividendYield = dividend yield
%v = vector of model parameters
%% -----------------------------------------------------------------------
V0=v(1);ThetaV=v(2);Kappa=v(3);SigmaV=v(4);RhoSV=v(5);JumpFreq=v(6);mj=v(7);JumpVol=v(8);shigh=v(9);
N=height(optiondata);
Strike=optiondata{:,1};
callprice=zeros(N,1);
for i=1:N
    callprice(i)=optbySVJEJ2(Strike(i),Times,Price,Rate,DividendYield,V0,ThetaV,Kappa,SigmaV,RhoSV,...
        JumpFreq,mj,JumpVol,0,0,0,shigh);
end

iv=zeros(N,1);
for i=1:N
    iv(i)=blsimpv(Price,Strike(i),Rate,Times,callprice(i),[],DividendYield);
end
mse=zeros(N,1);
for i=1:N
    mse(i,:)=(iv(i,:)-optiondata{i,2}).^2;
end
RMSE=sqrt((1/N)*sum(mse));
end

